﻿using UnityEngine;
using UnityEditor;
using System.Collections;

namespace Hont.C2UTool
{
    public class C2UStructs
    {
        public class SubComponentStruct
        {
            public IC2UAnimationInfoAnalyzer[] AnimationInfoAnalyzersArr;
            public IC2UStaticInfoAnalyzer[] StaticInfoAnalyzersArr;
        }

        public class ContextStruct
        {
            public GameObject InstancedGO;
            /// <summary>
            /// This value will delay update.
            /// </summary>
            public AnimationClip AnimationClip;
            public ModelImporter ModelImporter;
            public string FBXAssetsPath;
            public string FBXAssetsDirectoryPath;
            public string FBXName;
            public string DirectoryPath;
        }

        public class BaseInfoStruct
        {
            /// <summary>
            /// In Unity directory file.
            /// </summary>
            public string FBXPath;
            /// <summary>
            /// In C4D Export directory file.
            /// </summary>
            public string C4DFilePath;

            /// <summary>
            /// When a prefab file need in different directories, you can set this path.
            /// </summary>
            public string PrefabAttachOutputPath;
            /// <summary>
            /// When a animation file need in different directories, you can set this path.
            /// </summary>
            public string AnimationAttachOutputPath;

            /// <summary>
            /// Whether used the legacy animation.
            /// </summary>
            public bool IsLegacyAnimation;
            /// <summary>
            /// Whether used the loop animation.
            /// </summary>
            public bool IsLoopAnimation;
            /// <summary>
            /// Whether enabled non-legacy animation root motion.
            /// </summary>
            public bool IsEnableRootMotion;

            public bool IsKeyframedAllObjects;

            public ModelImporterAnimationCompression AnimationCompressionType;
            public float PositionCompressionError;
            public float ScaleCompressionError;
            public float RotationCompressionError;
            public bool BuildAvatarInfo;

            public string RootBoneName;

            /// <summary>
            /// Fbx file fps.
            /// </summary>
            public float FrameRate;

            public string DefaultShader;
        }

        public class AnimationCurveInfoStruct
        {
            public string Name;
            public AnimationCurve Curve;
        }

        public class AnimationInfoStruct
        {
            public string Path;
            public string Property;
            public System.Type Type;
            public KeyframeInfoStruct[] Keyframes;

            public override string ToString()
            {
                return string.Format("AnimationInfoStruct - Path:{0} Prop:{1} Type:{2} Keyframes:{3}", Path, Property, Type, Keyframes);
            }
        }

        public class AnimationEventInfoStruct
        {
            public float Time;
            public string MethodName;
            public int Argument;
        }

        public class KeyframeInfoStruct
        {
            public float Time;
            public object Value;
        }

        public class StaticInfoArgumentStruct
        {
            public string FieldName;
            public object Value;
        }

        public class StaticInfoStruct
        {
            public string GameObjectPath;
            public string ComponentName;
            public StaticInfoArgumentStruct[] Values;
        }

        public class MaterialInfoStruct
        {
            public string MaterialName;
            public string LinkedImageName;
            /// <summary>
            /// Used current material object array.
            /// </summary>
            public string[] UsedMatObjectArray;
            public ShaderInfoStruct ShaderInfo;
        }

        public class ShaderInfoStruct
        {
            public string ShaderName;
            public ShaderFieldStruct[] Values;
        }

        public struct ShaderFieldStruct
        {
            public string Key;
            public string Type;
            public object Value;

            public override string ToString()
            {
                return string.Format("ShaderFieldStruct - Key:{0} Type:{1} Value:{2}", Key, Type, Value);
            }
        }

        public ContextStruct ContextInfo;
        public SubComponentStruct SubComponentInfo;
        public BaseInfoStruct BaseInfo;
        public AnimationInfoStruct[] AnimationInfoArr;
        public AnimationEventInfoStruct[] AnimationEventInfoArr;
        public AnimationCurveInfoStruct[] AnimationCurveInfoArr;
        public StaticInfoStruct[] StaticInfoArr;
        public MaterialInfoStruct[] MaterialInfoArr;
    }
}